package cn.kgc.service.impl;

import cn.kgc.dao.UserDao;
import cn.kgc.domain.User;
import cn.kgc.service.UserService;
import cn.kgc.utils.myBatisUtil;

import java.util.List;

/**
 * @author Rock
 * @create 2019-11-14 14:36
 */
public class UserServiceImpl implements UserService {
    private UserDao dao = myBatisUtil.getSession(true).getMapper(UserDao.class);

    @Override
    public List<User> FindAll() {
        return dao.findAll();
    }

    @Override
    public int deleteUserById(String id) {
        int count = dao.deleteUserById(Integer.parseInt(id));
        return count;
    }

    @Override
    public int addUser(User user) {
        int count = dao.addUser(user);
        return count;
    }

    @Override
    public User findUserById(String id) {
        User user = dao.findById(Integer.parseInt(id));
        return user;
    }

    @Override
    public int updateUser(User user) {
        int i = dao.updateUser(user);
        return i;
    }

    @Override
    public List<User> findUserByCondition(User user) {
        return dao.findUserByCondition(user);
    }

}
